﻿using System;
using Autodesk.Revit.UI;
using YArchitech.Controls;

namespace ModelValidation.AdjoinFireZone
{
	public class AdjoinFireZoneHandler : IExternalEventHandler
	{
		public Request Request
		{
			get
			{
				return this.m_request;
			}
		}

		public void SetForm(ViewNotFitWinListForm formViewList)
		{
			this.m_formViewList = formViewList;
		}

		public string GetName()
		{
			return "AdjoinFire External Event";
		}

		public void Execute(UIApplication uiapp)
		{
			try
			{
				switch (this.Request.Take())
				{
				case RequestId.None:
					return;
				case RequestId.Renew:
					this.m_formViewList.CheckTolInfo();
					break;
				case RequestId.Settrust:
					this.m_formViewList.m_checkManage.SetTrustInfo();
					this.m_formViewList.CheckTolInfo();
					break;
				case RequestId.Replace:
					this.m_formViewList.ReplaceFamily();
					break;
				}
			}
			catch (Exception ex)
			{
				YJKMessageBox.Show(ex.Message);
			}
			finally
			{
				AdjoinFireZoneHorApplication.thisApp.WakeFormUp();
			}
		}

		private ViewNotFitWinListForm m_formViewList;

		private Request m_request = new Request();
	}
}
